package com.zebraphp.devtool.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.util.Linkify;
import android.view.View;
import android.widget.TextView;

import com.zebraphp.devtool.R;


/**
 * Created by Administrator on 2018/3/28.
 */

public class IDialog {

    public interface ClickListener {
        void pressOk();
    }

    public static void showDialog(String title, String string, final ClickListener clickListener, final Activity context) {
        AlertDialog.Builder localBuilder = new AlertDialog.Builder(context);
        View localView = context.getLayoutInflater().inflate(R.layout.dialog_tips, null);

        TextView tvTitle = localView.findViewById(R.id.title);
        Typeface localTypeface = Typeface.createFromAsset(context.getAssets(), "Roboto-Thin.ttf");
        tvTitle.setTypeface(localTypeface);
        tvTitle.setText(title);

        TextView tvContent = localView.findViewById(R.id.content);
        SpannableString localSpannableString = new SpannableString(string);
        Linkify.addLinks(localSpannableString, Linkify.ALL);
        tvContent.setTypeface(localTypeface);
        tvContent.setText(localSpannableString);

        localBuilder.setView(localView).setPositiveButton("确定！",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
                clickListener.pressOk();
            }
        });
        localBuilder.show();
    }
}
